import request from "@/utils/request";
const Base = process.env.VUE_APP_BASE_API;
const Process = process.env.VUE_APP_PROCESS_API

import qs from "qs"
// 获取流程分类一级菜单
export const getProcessClassifyList = (query) => {
  return request({
    url: `${Base}/auditFeign/processSort/findFirstByName`,
    method: "get",
    params: query,
  });
};
// 获取流程管理列表
export const getProcessList = (query) => {
  return request({
    url: `${Base}/auditFeign/getDefinitions`,
    method: "get",
    params: query,

  });
};
// 查询表单详情
export const getFormById = (query) => {
  return request({
    url: `${Base}/auditFeign/electronic-form/selectFormById`,
    method: "get",
    params: query,
  });
};

// 获取流程定义全局表单id
export const getFormKeyByDefId = (query) => {
  return request({
    url: `${Base}/auditFeign/processDefinition/getFormKeyByDefId`,
    method: "get",
    params: query,
  });
};

//  启动实例并提交表单内容
export function startProInstance(data) {
  return request({
    url: `${Base}/auditFeign/startProInstance`,
    headers: { 'Content-Type': 'application/x-www-form-urlencoded;charset=UTF-8' },
    method: 'post',
    data: qs.stringify(data)
  })
}

// 获取我发起的流程列表
export function getMyInstanceList(query) {
  return request({
    url: `${Base}/auditFeign/getMyInstance`,
    method: "get",
    params: query,
    timeout: 35000,
  })
}

// 获取流程实例的全局表单和表单数据
export function getFromAndData(query) {
  return request({
    url: `${Base}/auditFeign/getFromAndData`,
    method: "get",
    params: query,
  })
}


// 撤回流程实例
export function cancelProcess(query) {
  return request({
    url: `${Base}/auditFeign/processInstance/cancelProcess`,
    method: "get",
    params: query,
  })
}

// 删除流程实例
export function deleteProInstances(data) {
  return request({
    url: `${Base}/auditFeign/processInstance/deleteProInstances`,
    headers: { 'Content-Type': 'application/x-www-form-urlencoded;charset=UTF-8' },
    method: 'delete',
    data: qs.stringify(data)
  })
}

// 获取高亮流程
export function getHighLine(query) {
  return request({
    url: `${Base}/auditFeign/processInstance/getHighLine`,
    method: 'get',
    params: query,
  })
}

// 获取流程定义xml
export function getProDefineXml(query) {
  return request({
    url: `${Base}/auditFeign/processDefinition/getProDefineXmlForPortal`,
    method: 'get',
    params: query,

  })
}